how to read file in segments and how to insert data into database table